<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>嵌套路由二级路由</title>
    <script src="https://unpkg.com/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
   
</head>
<body>
    <div id="app">
        <h1>Hello App!</h1>
        <router-view></router-view>
    </div>
    <script>
        //嵌套二次子路由
        const User = {
            template:`
            <div>
                <div>用户界面</div>
                <router-view></router-view>
            </div>
            `
        }
        const Profile = {
            template:`
            <div>我是二级路由profile</div>
            `
        }
        const Posts = {
            template:`
            <div>我是二级路由posts</div>
            `
        }
        const routes = [
            {
                path:"/user",
                component:User,
                //二次子路由/user/
                children:[
                    {
                        path:"profile",
                        component:Profile
                    },
                    {
                        path:"posts",
                        component:Posts
                    }
                ]
            }
        ];
        const router = new VueRouter({
            routes
        })
        const app = new Vue({
            el:"#app",
            router,
        })
    </script>
</body>
</html>